<%@page import="com.easou.web.utils.SpringContextUtil"%>
<%@page import="com.easou.web.vo.GameUserBO"%>
<%@page import="com.easou.doudizhu.operate.Room"%>
<%@page import="com.easou.web.service.GameUserService"%>
<%@page import="com.easou.doudizhu.operate.RoomManager"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="com.easou.cas.auth.EucAuthResult"%>
<%@page import="com.easou.doudizhu.global.Constant"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>游戏大厅</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<script type="text/javascript">
		function goRoom(roomId){
			<%
				 EucAuthResult result = (EucAuthResult) request.getSession().getAttribute(Constant.AUTH_RESULT);
				 if(result!=null){
				 	Room room=RoomManager.getRoom(1);
				 	GameUserService service=(GameUserService)SpringContextUtil.getBean("GameUserService");
				 	GameUserBO bo= service.searchByUserId(result.getUser().getId());
					if(room!=null){
						if(bo.getBeanfun()>=room.getBeanfun()){
			%>
							window.location.href="room.jsp?roomId="+roomId+"&playerId=AAA"; 
			<%			
						}else{
			%>
						document.getElementById('tishi').innerHTML="您的乐豆符合入场条件:您的乐豆<%=bo.getBeanfun()%>,入场需要的乐豆:<%=room.getBeanfun()%>"
			<%
						}
					}
				}
			%>			 
		}
		
	</script>

  </head>
  
  <body>
  	<%
       if(result!=null){    
    %>
    <%=result.getUser().getNickName() %>&nbsp;欢迎您，   登录游戏成功！
    <%
       }else{
    %>
                           您还未登录！
    <%   
       }
     %>
  	<table>
  	<tr>
  	<td width="200px">
     	<input type="button" onclick="goRoom(1);" value="普通场" />
    </td>
    <td width="200px">
     	<input type="button" onclick="goRoom(2);" value="高分场" />
    </td>
   	<td>
     	<input type="button" onclick="goRoom(1);" value="适配开局" />
   	</td>
   	</tr>
   	</table>
   	<div id="tishi"></div>
  </body>
</html>
